 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="title">
            <h2><a href="#" class="back" onclick="history.go(-1)"/>Cadastrar Usuário</h2>
        </ui:define>

        <ui:define name="body">

            <h:form id="clienteForm" enctype="multipart/form-data">            
                <p:messages id="messages" closable="true" showDetail="true" autoUpdate="true"  />
                <p:panel id="dadosGeraisPanel" styleClass="container_24 clearfix">
                    <h2><a href="#">Dados Gerais</a></h2>
                    <br/>
                    <p:outputLabel value="Nome:" styleClass="grid_3" for="nomeInputText"/>
                    <p:inputText id="nomeInputText" styleClass="grid_18" value="#{managerCriarUsuario.usuario.nome}"/>
                    <div class="clear"/>
                    <p:outputLabel value="Contato:" styleClass="grid_3" for="telInputText"/>
                    <p:inputMask  id="telInputText" mask="(99)9999-9999" styleClass="grid_5" value="#{managerCriarUsuario.usuario.telefone}"/>
                    <!--                        <div class="clear"/>-->
                    <p:outputLabel value="Email:" styleClass="grid_2" for="emailInputText"/>
                    <p:inputText id="emailInputText" styleClass="grid_10" style="width: 43%" value="#{managerCriarUsuario.usuario.email}"/>

                </p:panel> 

                <p:panel id="setorPanel" styleClass="container_24 clearfix">
                    <h2><a href="#">Setor</a></h2>
                    <br/>
                    <!--                        <p:outputLabel value="Setor : " styleClass="grid_3"/>
                                            <p:inputText styleClass="grid_18" value="{managerCriarUsuario.setor.nome}" readonly="true"/>
                                            <p:commandButton icon="ui-icon-circle-plus" oncomplete="dlg.show();"/>-->
                    <p:outputLabel  for="secInput" value="Secretaria:" styleClass="grid_3"/>  
                    <div class="grid_8"> 
                        <p:selectOneMenu value="#{managerCriarUsuario.secretariaPesquisar}" id="secInput" 
                                         converter="secretariaconverter" >  
                            <f:selectItem  itemValue="" itemLabel=""/>
                            <f:selectItems value="#{managerCriarUsuario.todasSecretarias()}" var="p" 
                                           itemLabel="#{p.nome}" itemValue="#{p}"/>  
                            <p:ajax listener="#{managerCriarUsuario.todosSetoresSec()}" update=":clienteForm:setInput"/>
                        </p:selectOneMenu> 
                    </div> 
                    <p:outputLabel for="setInput" value="Setor:" styleClass="grid_3"/> 
                    <div class="grid_8">
                        <p:selectOneMenu value="#{managerCriarUsuario.setor}" id="setInput" converter="setorconverter"
                                         effect="fade">  
                            <f:selectItem  itemValue="" itemLabel=""/>
                            <f:selectItems value="#{managerCriarUsuario.setores}" var="p" itemLabel="#{p.nome}" itemValue="#{p}"/>  
                        </p:selectOneMenu> 
                    </div>
                </p:panel>

                <p:panel id="loginPanel" styleClass="container_24 clearfix">
                    <h2><a href="#">Acesso</a></h2>
                    <br/>
                    <p:outputLabel value="Login:" styleClass="grid_3" for="loginInputText"/>
                    <p:inputText id="loginInputText" styleClass="grid_10" value="#{managerCriarUsuario.usuario.login}">
                        <p:ajax event="blur" update=":clienteForm:loginErroPanel" 
                                listener="#{managerCriarUsuario.existLogin()}"/>
                    </p:inputText>
                    <p:panel id="loginErroPanel" styleClass="grid_4 clearfix" 
                             style="border: none; margin: -13px 0 0 -20px;">
                        <p:outputLabel id="loginExistenteOutputLabel" value="Login já existe" 
                                       rendered="#{managerCriarUsuario.login}" 
                                       styleClass="grid_23" style="color: red;"/>
                    </p:panel>

                    <div class="clear"/>
                    <p:outputLabel value="Senha:" styleClass="grid_3" for="senhaPassword"/>
                    <p:password id="senhaPassword" styleClass="grid_10" 
                                value="#{managerCriarUsuario.usuario.senha}"
                                promptLabel="Digite uma senha segura" weakLabel="Razoável"
                                goodLabel="Boa" strongLabel="Excelente" feedback="true"/>
                    <div class="clear"/>
                    <p:outputLabel value="Repitir Senha:" styleClass="grid_3" for="repetirSenhaPassword"/>
                    <p:password id="repetirSenhaPassword" styleClass="grid_10" value="#{managerCriarUsuario.senha}" 
                                promptLabel="Digite uma senha segura" weakLabel="Razoável"
                                goodLabel="Boa" strongLabel="Excelente" feedback="true"/>  
                </p:panel>
                <p:panel id="adminPanel" styleClass="container_24 clearfix">
                    <h2><a href="#">Administração</a></h2>
                    <br/>
                    <p:pickList id="picklistGrupos"  style="margin-top: 10px"
                                showSourceFilter="true" showTargetFilter="true"
                                value="#{managerCriarUsuario.dualGrupo}" var="grupo"
                                itemLabel="#{grupo.descricao}" converter="grupoconverter" itemValue="#{grupo}">
                        <f:facet name="sourceCaption">Grupo</f:facet>	
                        <f:facet name="targetCaption">Grupo Selecionados</f:facet>
                    </p:pickList>

                </p:panel> 
                <br/>
                <br/>

                <div class="buttonAction">
                    <p:commandButton value="Salvar" actionListener="#{managerCriarUsuario.salvar()}"
                                     icon="ui-icon-disk" styleClass="ui-priority-primary"
                                     update="@form" />
                    <p:button value="Cancelar" icon="ui-icon-circle-close"
                              href="indexusuario.xhtml" />
                </div>
            </h:form>
        </ui:define>
    </ui:composition>
</html>



